/*
 * @Descripttion: 
 * @Author: junhuafly
 * @Date: 2020-03-09 17:35:34
 * @LastEditors: junhuafly
 * @Email: junhuafly@163.com
 * @LastEditTime: 2020-04-10 10:59:17
 */

import { orderAPI } from "../../../../../api/index";
import {
  returnStatus,
  returnStatusToast,
  getPromise
} from '../../../../../utils/index'

// pages/mine/order/afterorder/type/index.js
var appInst =  getApp();

Page({

  /**
   * 页面的初始数据
   */
  data: {
    order_switch_icon: {
      1: '/pages/images/icon/me_order_refunds_icon@2x.png',
      2: '/pages/images/icon/me_order_refund_icon@2x.png',
      3: '/pages/images/icon/me_order_cancel_icon@2x.png',
      4: '/pages/images/icon/me_order_exchange_icon@2x.png',
    }
  },

  toGoods({currentTarget:{dataset:{code,name}}}){
    if(code===4) return
    wx.navigateTo({
      url: '/pages/mine/order/afterOrder/pay&goods/index',
      success: (res)=>{
        res.eventChannel.emit('params', { info:this.data.info, code,title:name })
      },
      fail: ()=>{},
      complete: ()=>{}
    });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    appInst.setTitle('选择售后类型')
    const eventChannel = this.getOpenerEventChannel()
    eventChannel.on('params', ({info})=>{
      this.setData({info})
    });

    // 获取售后类型
    orderAPI.queryAfterType().then(async res=>{
      const _ = await returnStatus(res)
      this.setData({order_switch:_.aftersaleTypes})
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})